package com.sdy.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class DateUtil {


//    public static void main(String[] args) {
//
//        String s = new Date().toString();
//        System.out.println(s);
//        System.out.println(getTimeStamp(s));
//    }


    /**
     * 根据传入的字符串获得
     * 秒级时间戳的倒叙
     */
    public static String getTimeStamp(String timeString){

        Date date = null;

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
        try {
            date = simpleDateFormat.parse(timeString);
        } catch (ParseException e) {
            e.printStackTrace();
            System.out.println("没有此日期");
        }

        String result = String.valueOf(date.getTime());

        result = Integer.valueOf(result.substring(0,result.length()-3)).toString();

        StringBuffer buffer = new StringBuffer(result);

        return buffer.reverse().toString();
    }
}
